package demo04;

import java.awt.List;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;

public class DouDiZhu {
	public static void main(String[] args) {
		
		HashMap<Integer,String> poker = new HashMap<Integer,String>();
		ArrayList<Integer> pokerindex = new ArrayList<>();
		String[] colors={"♠","♣","♦","♥"};
		String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
		int index=0;
		poker.put(index,"大王");
		pokerindex.add(index);
		index++;
		poker.put(index,"小王");
		pokerindex.add(index);
		index++;
		for(String number:numbers){
			for(String color:colors){
				poker.put(index,color+number);
				pokerindex.add(index);
				index++;
			}
		}
		System.out.println(poker);
		System.out.println(pokerindex);
		Collections.shuffle(pokerindex);
		System.out.println(pokerindex);
		Player p1=new Player("老王");
		Player p2=new Player("老李");
		Player p3=new Player("老刘");
		ArrayList<Integer> dipai = new ArrayList<Integer>();
		for(int i=0;i<pokerindex.size();i++){
			int p=pokerindex.get(i);
			if(i>=51){
				dipai.add(p);
			}else if(i%3==0){
				p1.getPoker().add(p);
			}else if(i%3==1){
				p2.getPoker().add(p);
			}else if(i%3==2){
				p3.getPoker().add(p);
			}
		}
		Collections.sort(p1.getPoker());
		Collections.sort(p2.getPoker());
		Collections.sort(p3.getPoker());
		Collections.sort(dipai);
		lookpoker(p1,poker);
		lookpoker(p2,poker);
		lookpoker(p3,poker);
		lookpoker(dipai,poker);
	}

	private static void lookpoker(ArrayList<Integer> dipai, HashMap<Integer, String> poker) {
		System.out.print("底牌：");
		for (Integer key : dipai) {
			String value=poker.get(key);
			System.out.print(value+" ");
		}
		
	}

	private static void lookpoker(Player p, HashMap<Integer, String> poker) {
		System.out.print(p.getName()+"的牌：");
		for (Integer key : p.getPoker()) {
			String value=poker.get(key);
			System.out.print(value+" ");
		}
		System.out.println();
		
	}


}
